package com.zdkj.subway.check.service.impl.subwayRat.fareDifferencesInAudit;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zdkj.common.security.service.PigxUser;
import com.zdkj.subway.check.entity.*;
import com.zdkj.subway.check.mapper.*;
import com.zdkj.subway.check.service.FareDifferencesInAuditService;
import com.zdkj.subway.check.service.SwAuTvmBoxAmountDifferenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import com.zdkj.subway.check.util.DateFormat;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * TVM单台设备审核
 */
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class FareDifferencesInAuditServiceImpl extends ServiceImpl<FareDifferencesInAuditMapper,FareDifferencesInAudit> implements FareDifferencesInAuditService {

    @Autowired
    private FareDifferencesInAuditMapper fareDifferencesInAuditMapper;
    @Autowired
    private FareDifferencesInAuditService fareDifferencesInAuditService;
	@Autowired
    private SwAuTvmAmountDefferenceMapper swAuTvmAmountDefferenceMapper;
    @Autowired
    private SwAuTvmBoxAmountDifferenceService swAuTvmBoxAmountDifferenceService;
    @Autowired
    private SwAuTvmDailyBillAssistMapper swAuTvmDailyBillAssistMapper;
    @Autowired
    private SwAuTvmDailyBillAssistDetailMapper swAuTvmDailyBillAssistDetailMapper;
    @Autowired
    private SwAuTvmSingleAssistMapper swAuTvmSingleAssistMapper;
    @Autowired
    private SwAuTvmCashAmountHierarchyDifferenceMapper swAuTvmCashAmountHierarchyDifferenceMapper;
    @Resource
    private SysUserMapper sysUserMapper;
    @Resource
    private SwStTvmCheckDetailMapper swStTvmCheckDetailMapper;
    @Resource
    private CashboxUninstallMapper cashboxUninstallMapper;
    @Resource
    private SwStTvmIncomeSettleMapper swStTvmIncomeSettleMapper;
    @Resource
    private SwAuTvmBoxAmountDifferenceMapper swAuTvmBoxAmountDifferenceMapper;
    @Resource
    private SwAuTvmMoneyAssistMapper swAuTvmMoneyAssistMapper;
    @Resource
    private SwStHandworkCleanRecordMapper swStHandworkCleanRecordMapper;
    @Resource
    private SwStHandworkCleanRecordDetailsMapper swStHandworkCleanRecordDetailsMapper;
    @Resource
    private SwStTvmSupplementCurrencyMapper swStTvmSupplementCurrencyMapper;
    @Resource
    private SwStTvmSupplementCurrencyDetailsMapper swStTvmSupplementCurrencyDetailsMapper;

    /**
     * TVM票款差异审核
     * @param page
     * @param param
     * @return
     */
    public IPage<FareDifferencesInAudit> getFareDifferencesInAudit(Page page, Map<String, Object> param) {
        /*Map<String,Object> p1=new HashMap<>();
        String lineCode = param.get("lineCode");
        String stationCode = param.get("stationCode");
        if(StringUtils.isNotEmpty(lineCode) || StringUtils.isNotEmpty(stationCode)){
            List<Map<String, Object>> maps = fareDifferencesInAuditMapper.getFareDifferencesInAudit(param);
            return maps;
        }
        p1.put("user_code",param.get("userCode"));
        List<SysUser> sysUsers = sysUserMapper.selectByMap(p1);
        SysUser sysUser = sysUsers.get(0);
        String managementLineStation = sysUser.getManagementLineStation();
        managementLineStation= StringUtils.isEmpty(managementLineStation)?"[]":managementLineStation;
        JSONArray managementLineStations = JSONArray.parseArray(managementLineStation);
        List<Map<String,Object>> fareDifferencesInAudits=new ArrayList<>();
        for(int i=0;i<managementLineStations.size();i++){
            JSONObject jsonObject = managementLineStations.getJSONObject(i);
            String line = jsonObject.getString("line");
            String station = jsonObject.getString("station");
            param.put("lineCode",line);
            param.put("stationCode",station);
            List<Map<String,Object>> reportErrorAlterAppayOne = fareDifferencesInAuditMapper.getFareDifferencesInAudit(param);
            fareDifferencesInAudits.addAll(reportErrorAlterAppayOne);
        }*/
        IPage<FareDifferencesInAudit> maps = fareDifferencesInAuditMapper.getFareDifferencesInAudit(page,param);
        return maps;
    }

    /**
     * 设置差异原因
     * @param param
     */
    public void updateDifferences(Map param){
        List<Integer> ids = (List)JSONObject.parseArray(String.valueOf(param.get("ids")));
        String textarea = String.valueOf(param.get("textarea"));
        for(Integer id : ids){
            FareDifferencesInAudit fareDifferencesInAudit = new FareDifferencesInAudit();
            fareDifferencesInAudit.setId(Long.valueOf(id));
            fareDifferencesInAudit.setDiffReason(textarea);
            fareDifferencesInAuditMapper.updateDifferences(fareDifferencesInAudit);
        }
    }

    /**
     * 一键审核
     * @param param
     * @param user
     */
    public void updateAuditStatusDefference(Map param,PigxUser user){		
        List<Integer> ids = (List)JSONObject.parseArray(String.valueOf(param.get("ids")));
        for(Integer id : ids){
            FareDifferencesInAudit fareDifferencesInAudit = new FareDifferencesInAudit();
            fareDifferencesInAudit.setId(Long.valueOf(id));
            fareDifferencesInAudit.setAuditStatus("1");
            fareDifferencesInAudit.setAuditTime(new Date());
			fareDifferencesInAudit.setAuditPersonCode(user.getUserCode());
            fareDifferencesInAudit.setAuditPersonName(user.getNikeName());
            fareDifferencesInAuditMapper.updateDifferences(fareDifferencesInAudit);
        }
    }

    /**
     * 加入结账单据协查或者单台设备差异协查
     * @param param 1为结账单据协查 2为单台设备协查
     */
    public void insertCheckTheDocumentsInvestigation(Map param){
        List<Integer> ids = (List)JSONObject.parseArray(String.valueOf(param.get("ids")));
        String type = String.valueOf(param.get("type"));
        for(Integer id : ids){
            FareDifferencesInAudit fareDifferencesInAudit = new FareDifferencesInAudit();
            fareDifferencesInAudit.setId(Long.valueOf(id));
            FareDifferencesInAudit fareDifferencesInAuditById = fareDifferencesInAuditMapper.getFareDifferencesInAuditById(fareDifferencesInAudit);
            //1为结账单据协查 2为单台设备协查
            if("1".equals(type)){
                if(null != fareDifferencesInAuditById && "1".equals(fareDifferencesInAuditById.getDataSource()) &&
//                        null != fareDifferencesInAuditById.getSystemMoney() && new BigDecimal(0).compareTo(fareDifferencesInAuditById.getSystemMoney()) == 0 &&
                        null != fareDifferencesInAuditById.getIsAddSettleorderAssist() && !"1".equals(fareDifferencesInAuditById.getIsAddSettleorderAssist())){
                    SwAuTvmDailyBillAssist swAuTvmDailyBillAssist = new SwAuTvmDailyBillAssist();
                    swAuTvmDailyBillAssist.setRelationid(Integer.valueOf(fareDifferencesInAuditById.getId().toString()));
                    swAuTvmDailyBillAssist.setTvmCode(fareDifferencesInAuditById.getTvmCode());
                    swAuTvmDailyBillAssist.setLineCode(fareDifferencesInAuditById.getLineCode());
                    swAuTvmDailyBillAssist.setStationCode(fareDifferencesInAuditById.getStationCode());
                    SimpleDateFormat dff = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    swAuTvmDailyBillAssist.setIncomeTime(dff.format(fareDifferencesInAuditById.getRecordTime()));
                    swAuTvmDailyBillAssist.setCashTotal((fareDifferencesInAuditById.getTvmBillCashSellTicket().add(fareDifferencesInAuditById.getTvmBillCashRecharge()))
                    .subtract(fareDifferencesInAuditById.getTvmBillCashReturn()));
                    swAuTvmDailyBillAssist.setElecTotal((fareDifferencesInAuditById.getTvmBillElecSellTicket().add(fareDifferencesInAuditById.getTvmBillElecRecharge()))
                    .subtract(fareDifferencesInAuditById.getTvmBillElecReturn()));
                    swAuTvmDailyBillAssist.setIncomeSettleBeginTime(dff.format(fareDifferencesInAuditById.getIncomeSettleBeginTime()));
                    swAuTvmDailyBillAssist.setIncomeSettleEndTime(dff.format(fareDifferencesInAuditById.getIncomeSettleEndTime()));
                    swAuTvmDailyBillAssist.setElectromeReason("");
                    swAuTvmDailyBillAssist.setAssistInvestStatus("1");
                    swAuTvmDailyBillAssist.setReplyStatus("0");
                    swAuTvmDailyBillAssist.setReplaceStatus("0");
                    swAuTvmDailyBillAssist.setCreatorId(fareDifferencesInAuditById.getCreatorId());
                    swAuTvmDailyBillAssist.setCreatorName(fareDifferencesInAuditById.getCreatorName());
                    int respid = swAuTvmDailyBillAssistMapper.insertSwAuTvmDailyBillAssist(swAuTvmDailyBillAssist);
                    SwAuTvmDailyBillAssistDetail swAuTvmDailyBillAssistDetail = new SwAuTvmDailyBillAssistDetail();
                    swAuTvmDailyBillAssistDetail.setRelationid(swAuTvmDailyBillAssist.getId());
                    swAuTvmDailyBillAssistDetail.setTvmCode(fareDifferencesInAuditById.getTvmCode());
                    //现金支付部分
                    swAuTvmDailyBillAssistDetail.setReceiveNotes(fareDifferencesInAuditById.getTvmBillReceivePapaer());
                    swAuTvmDailyBillAssistDetail.setReceiveCoin(fareDifferencesInAuditById.getTvmBillReceiveCoins());
                    swAuTvmDailyBillAssistDetail.setReceiveMoney(fareDifferencesInAuditById.getTvmBillReceivePapaer().add(fareDifferencesInAuditById.getTvmBillReceiveCoins()));
                    swAuTvmDailyBillAssistDetail.setNoteChange(fareDifferencesInAuditById.getTvmBillNoteChange());
                    swAuTvmDailyBillAssistDetail.setCoinChange(fareDifferencesInAuditById.getTvmBillCoinChange());
                    swAuTvmDailyBillAssistDetail.setChangeTotalMoney(fareDifferencesInAuditById.getTvmBillNoteChange().add(fareDifferencesInAuditById.getTvmBillCoinChange()));
                    swAuTvmDailyBillAssistDetail.setSellTicketMoney(fareDifferencesInAuditById.getTvmBillCashSellTicket());
                    swAuTvmDailyBillAssistDetail.setRechargeTotal(fareDifferencesInAuditById.getTvmBillCashRecharge());
                    swAuTvmDailyBillAssistDetail.setReturnTotal(fareDifferencesInAuditById.getTvmBillCashReturn());
                    //现金支付回馈部分
                    swAuTvmDailyBillAssistDetail.setRReceiveNotes(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setRReceiveCoin(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setRReceiveMoney(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setRNoteChange(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setRCoinChange(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setRChangeTotalMoney(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setRSellTicketMoney(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setRRechargeTotal(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setRReturnTotal(new BigDecimal(0));
                    //电子支付部分
                    swAuTvmDailyBillAssistDetail.setESellTicketMoney(fareDifferencesInAuditById.getTvmBillElecSellTicket());
                    swAuTvmDailyBillAssistDetail.setERechargeTotal(fareDifferencesInAuditById.getTvmBillElecRecharge());
                    swAuTvmDailyBillAssistDetail.setEReturnTotal(fareDifferencesInAuditById.getTvmBillElecReturn());
                    //电子支付回馈部分
                    swAuTvmDailyBillAssistDetail.setRESellTicketMoney(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setRERechargeTotal(new BigDecimal(0));
                    swAuTvmDailyBillAssistDetail.setREReturnTotal(new BigDecimal(0));
                    //公共部分
                    swAuTvmDailyBillAssistDetail.setCreatorId(fareDifferencesInAuditById.getCreatorId());
                    swAuTvmDailyBillAssistDetail.setCreatorName(fareDifferencesInAuditById.getCreatorName());
                    int detailId = swAuTvmDailyBillAssistDetailMapper.insertSwAuTvmDailyBillAssistDetail(swAuTvmDailyBillAssistDetail);
                    fareDifferencesInAuditById.setIsAddSettleorderAssist("1");
                }
            }else if("2".equals(type)){
                if(null != fareDifferencesInAuditById.getIsAddSinglerAssist() && !"1".equals(fareDifferencesInAuditById.getIsAddSinglerAssist())){
                    SwAuTvmSingleAssist swAuTvmSingleAssist = new SwAuTvmSingleAssist();
                    swAuTvmSingleAssist.setRelationid(Integer.valueOf(fareDifferencesInAuditById.getId().toString()));
                    swAuTvmSingleAssist.setTvmCode(fareDifferencesInAuditById.getTvmCode());
                    swAuTvmSingleAssist.setLineCode(fareDifferencesInAuditById.getLineCode());
                    swAuTvmSingleAssist.setStationCode(fareDifferencesInAuditById.getStationCode());
                    swAuTvmSingleAssist.setIncomeTime(fareDifferencesInAuditById.getRecordTime());
                    swAuTvmSingleAssist.setActualMoney(fareDifferencesInAuditById.getActualMoney());
                    //系统金额
                    swAuTvmSingleAssist.setTvmBillOrderMoney(fareDifferencesInAuditById.getSystemMoney());
                    //差异金额
                    swAuTvmSingleAssist.setDiffMoney(fareDifferencesInAuditById.getDiffMoney());

                    BigDecimal depositAmount = fareDifferencesInAuditById.getScCashRecharge()==null?new BigDecimal(0):fareDifferencesInAuditById.getScCashRecharge();
                    BigDecimal saleAmount = fareDifferencesInAuditById.getScCashSellTicket()==null?new BigDecimal(0):fareDifferencesInAuditById.getScCashSellTicket();
                    BigDecimal errorRefundAmount = fareDifferencesInAuditById.getScCashReturn()==null?new BigDecimal(0):fareDifferencesInAuditById.getScCashReturn();

                    //充值   售票    退款
                    swAuTvmSingleAssist.setDepositAmount(depositAmount);
                    swAuTvmSingleAssist.setSaleAmount(saleAmount);
                    swAuTvmSingleAssist.setErrorRefundAmount(errorRefundAmount);

                    swAuTvmSingleAssist.setReplyDiffMoney(new BigDecimal(0));
                    swAuTvmSingleAssist.setAssistInvestStatus("1");
                    swAuTvmSingleAssist.setKyAssistInvestStatus("1");
                    swAuTvmSingleAssist.setReplyStatus("0");
                    swAuTvmSingleAssist.setKyReplyStatus("0");
                    swAuTvmSingleAssist.setReplaceStatus("0");
                    swAuTvmSingleAssist.setCreatorId(fareDifferencesInAuditById.getCreatorId());
                    swAuTvmSingleAssist.setCreatorName(fareDifferencesInAuditById.getCreatorName());


                    swAuTvmSingleAssistMapper.insertSwAuTvmSingleAssist(swAuTvmSingleAssist);
                    fareDifferencesInAuditById.setIsAddSinglerAssist("1");
                }
            }
            fareDifferencesInAuditMapper.updateDifferences(fareDifferencesInAuditById);
        }
    }

    /**
     * 加入层级差异协查
     * @param param ids,层级类型
     * @return
     */
    public void insertSwAuTvmCashAmountHierarchyDifference(Map param){
        List<Integer> ids = (List)JSONObject.parseArray(String.valueOf(param.get("ids")));
        List<String> types = (List)JSONObject.parseArray(String.valueOf(param.get("types")));
        for(Integer id : ids){
            FareDifferencesInAudit fareDifferencesInAudit = new FareDifferencesInAudit();
            fareDifferencesInAudit.setId(Long.valueOf(id));
            for(String type : types){
                FareDifferencesInAudit fareDifferencesInAuditById = fareDifferencesInAuditMapper.getFareDifferencesInAuditById(fareDifferencesInAudit);
                SwAuTvmCashAmountHierarchyDifference swAuTvmCashAmountHierarchyDifference = new SwAuTvmCashAmountHierarchyDifference();
                swAuTvmCashAmountHierarchyDifference.setRelationSourceId(Integer.valueOf(fareDifferencesInAuditById.getId().toString()));
                swAuTvmCashAmountHierarchyDifference.setLineCode(fareDifferencesInAuditById.getLineCode());
                swAuTvmCashAmountHierarchyDifference.setStationCode(fareDifferencesInAuditById.getStationCode());
                swAuTvmCashAmountHierarchyDifference.setSettleTime(fareDifferencesInAuditById.getRecordTime());
                swAuTvmCashAmountHierarchyDifference.setTvmOrder(fareDifferencesInAuditById.getTvmCode());
                String typeCode = "";
                BigDecimal cashRecharge = new BigDecimal(0);
                BigDecimal cashSellTicket = new BigDecimal(0);
                BigDecimal cashReturn = new BigDecimal(0);

                BigDecimal depositAmount = new BigDecimal(0);
                BigDecimal saleAmount = new BigDecimal(0);
                BigDecimal errorRefundAmount = new BigDecimal(0);
                if("SC".equals(type)){
                    if(null != fareDifferencesInAuditById.getIsAddScLevelAssist() && "1".equals(fareDifferencesInAuditById.getIsAddScLevelAssist())){
                        continue;
                    }
                    typeCode = "2";
                    cashRecharge = fareDifferencesInAuditById.getScCashRecharge();
                    cashSellTicket = fareDifferencesInAuditById.getScCashSellTicket();
                    cashReturn = fareDifferencesInAuditById.getScCashReturn();
                    fareDifferencesInAuditById.setIsAddScLevelAssist("1");
                }
                if("SC-LC".equals(type)){
                    if(null != fareDifferencesInAuditById.getIsAddLcLevelAssist() && "1".equals(fareDifferencesInAuditById.getIsAddLcLevelAssist())){
                        continue;
                    }
                    typeCode = "3";
                    depositAmount = fareDifferencesInAuditById.getScCashRecharge()==null?new BigDecimal(0):fareDifferencesInAuditById.getScCashRecharge();
                    saleAmount = fareDifferencesInAuditById.getScCashSellTicket()==null?new BigDecimal(0):fareDifferencesInAuditById.getScCashSellTicket();
                    errorRefundAmount = fareDifferencesInAuditById.getScCashReturn()==null?new BigDecimal(0):fareDifferencesInAuditById.getScCashReturn();

                    cashRecharge = fareDifferencesInAuditById.getLcCashRecharge()==null?new BigDecimal(0):fareDifferencesInAuditById.getLcCashRecharge();
                    cashSellTicket = fareDifferencesInAuditById.getLcCashSellTicket()==null?new BigDecimal(0):fareDifferencesInAuditById.getLcCashSellTicket();
                    cashReturn = fareDifferencesInAuditById.getLcCashReturn()==null?new BigDecimal(0):fareDifferencesInAuditById.getLcCashReturn();
                    fareDifferencesInAuditById.setIsAddLcLevelAssist("1");
                }
                if("LC-ACC".equals(type)){
                    if(null != fareDifferencesInAuditById.getIsAddAccLevelAssist() && "1".equals(fareDifferencesInAuditById.getIsAddAccLevelAssist())){
                        continue;
                    }
                    typeCode = "4";
                    depositAmount = fareDifferencesInAuditById.getLcCashRecharge()==null?new BigDecimal(0):fareDifferencesInAuditById.getLcCashRecharge();
                    saleAmount = fareDifferencesInAuditById.getLcCashSellTicket()==null?new BigDecimal(0):fareDifferencesInAuditById.getLcCashSellTicket();
                    errorRefundAmount = fareDifferencesInAuditById.getLcCashReturn()==null?new BigDecimal(0):fareDifferencesInAuditById.getLcCashReturn();

                    cashRecharge = fareDifferencesInAuditById.getAccCashRecharge()==null?new BigDecimal(0):fareDifferencesInAuditById.getAccCashRecharge();
                    cashSellTicket = fareDifferencesInAuditById.getAccCashSellTicket()==null?new BigDecimal(0):fareDifferencesInAuditById.getAccCashSellTicket();
                    cashReturn = fareDifferencesInAuditById.getAccCashReturn()==null?new BigDecimal(0):fareDifferencesInAuditById.getAccCashReturn();
                    fareDifferencesInAuditById.setIsAddAccLevelAssist("1");
                }
                swAuTvmCashAmountHierarchyDifference.setType(typeCode);
//                swAuTvmCashAmountHierarchyDifference.setDepositAmount(fareDifferencesInAuditById.getTvmBillCashRecharge());
//                swAuTvmCashAmountHierarchyDifference.setSaleAmount(fareDifferencesInAuditById.getTvmBillCashSellTicket());
//                swAuTvmCashAmountHierarchyDifference.setErrorRefundAmount(fareDifferencesInAuditById.getTvmBillCashReturn());

                //如果是SC-LC存SC   否则存LC
                swAuTvmCashAmountHierarchyDifference.setDepositAmount(depositAmount);
                swAuTvmCashAmountHierarchyDifference.setSaleAmount(saleAmount);
                swAuTvmCashAmountHierarchyDifference.setErrorRefundAmount(errorRefundAmount);

                swAuTvmCashAmountHierarchyDifference.setCompareType(typeCode);
                //如果是SC-LC存LC   否则存ACC
                swAuTvmCashAmountHierarchyDifference.setBeDepositAmount(cashRecharge);
                swAuTvmCashAmountHierarchyDifference.setBeSaleAmount(cashSellTicket);
                swAuTvmCashAmountHierarchyDifference.setBeErrorRefundAmount(cashReturn);

                swAuTvmCashAmountHierarchyDifference.setAssistStatus("1");
                swAuTvmCashAmountHierarchyDifference.setReplaceStatus("0");
                swAuTvmCashAmountHierarchyDifference.setDataType("1");
                swAuTvmCashAmountHierarchyDifference.setCreatorId(fareDifferencesInAuditById.getCreatorId());
                swAuTvmCashAmountHierarchyDifference.setCreateTime(new Date());
                swAuTvmCashAmountHierarchyDifferenceMapper.insertSwAuTvmCashAmountHierarchyDifference(swAuTvmCashAmountHierarchyDifference);
                fareDifferencesInAuditMapper.updateDifferences(fareDifferencesInAuditById);
            }
        }
    }
    /**
     * TVM票款差异审核-加入通知
     * @param
     * @return
     */
    public void jiaRuNoticeTvm(Map param) {
        List<Integer> ids = (List)JSONObject.parseArray(String.valueOf(param.get("ids")));
        List<FareDifferencesInAudit> list = new ArrayList<>();

        for(Integer id : ids){
            FareDifferencesInAudit fareDifferencesInAudit = new FareDifferencesInAudit();
            fareDifferencesInAudit.setId(Long.valueOf(id));
            //已通知
            fareDifferencesInAudit.setNoticeSate("2");
            //通知时间
            fareDifferencesInAudit.setSendTime(new Date());
            list.add(fareDifferencesInAudit);
        }
        fareDifferencesInAuditService.updateBatchById(list);
    }

    /**
     * 作废TVM数据
     * @param param
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean invalidTvmData(Map<String,String> param) {
        String lineCode = param.get("lineCode");
        String stationCode = param.get("stationCode");
        String tvmCode = param.get("tvmCode");
        String recordTime = param.get("recordTime");
        String delFlag = "0";
		
		if(StringUtils.isEmpty(lineCode) || StringUtils.isEmpty(stationCode) || StringUtils.isEmpty(tvmCode) || StringUtils.isEmpty(recordTime)){
		   return false;
		 }
        //作废TVM钱箱清点数据
        LambdaQueryWrapper<SwStTvmCheckDetail> tvmCheckDetailWrapper = new LambdaQueryWrapper<>();
        tvmCheckDetailWrapper.eq(SwStTvmCheckDetail::getLineCode, lineCode)
                .eq(SwStTvmCheckDetail::getStationCode, stationCode)
                .eq(SwStTvmCheckDetail::getTvmCode, tvmCode)
                .eq(SwStTvmCheckDetail::getRevenueTime, recordTime)
                .eq(SwStTvmCheckDetail::getDelFlag, delFlag);
        SwStTvmCheckDetail swStTvmCheckDetail = new SwStTvmCheckDetail();
        swStTvmCheckDetail.setDelFlag("1");
        swStTvmCheckDetail.setInvalidStatus("1");
        swStTvmCheckDetailMapper.update(swStTvmCheckDetail, tvmCheckDetailWrapper);
        //作废钱箱未卸载数据、作废TVM钱箱未卸载审核数据
        LambdaQueryWrapper<SwStInputCashboxUninstalled> cashboxUninstalledWrapper = new LambdaQueryWrapper<>();
        cashboxUninstalledWrapper.eq(SwStInputCashboxUninstalled::getLineCode, lineCode)
                .eq(SwStInputCashboxUninstalled::getStationCode, stationCode)
                .eq(SwStInputCashboxUninstalled::getTvmCode, tvmCode)
                .eq(SwStInputCashboxUninstalled::getUninstalledDate, recordTime)
                .eq(SwStInputCashboxUninstalled::getDelFlag, delFlag);
        SwStInputCashboxUninstalled swStInputCashboxUninstalled = new SwStInputCashboxUninstalled();
        swStInputCashboxUninstalled.setDelFlag("1");
        swStInputCashboxUninstalled.setInvalidStatus("1");
        cashboxUninstallMapper.update(swStInputCashboxUninstalled, cashboxUninstalledWrapper);
        //作废补币金额管理数据 -- 不用
/*        List<SwStTvmSupplementCurrency> supplementCurrencyList =
                swStTvmSupplementCurrencyMapper.selectList(Wrappers.<SwStTvmSupplementCurrency>lambdaQuery()
                        .eq(SwStTvmSupplementCurrency::getLineCode, lineCode)
                        .eq(SwStTvmSupplementCurrency::getStationCode, stationCode)
                        .eq(SwStTvmSupplementCurrency::getSupplementCurrencyTime, recordTime)
                        .eq(SwStTvmSupplementCurrency::getDelFlag, "0"));
        List<SwStTvmSupplementCurrencyDetails> detailsInvalidList = new ArrayList<>();
        //循环主表--处理子表  根据主表id找对应的子表 --统计子表各tvm金额
        for (SwStTvmSupplementCurrency currency : supplementCurrencyList) {
            Integer id = currency.getId();
            List<SwStTvmSupplementCurrencyDetails> detailsList =
                    swStTvmSupplementCurrencyDetailsMapper.selectList(Wrappers.<SwStTvmSupplementCurrencyDetails>lambdaQuery()
                            .eq(SwStTvmSupplementCurrencyDetails::getRelationId, id)
                            .eq(SwStTvmSupplementCurrencyDetails::getDelFlag, "0"));
            if(CollectionUtil.isNotEmpty(detailsList)){
                //根据TVM钱箱类型进行统计
                List<SwStTvmSupplementCurrencyDetails> collect =
                        detailsList.stream().filter(x -> "0".equals(x.getDelFlag()) && !tvmCode.equals(x.getTvmCode())).collect(Collectors.toList());
                if(CollectionUtil.isNotEmpty(collect)){
                    //纸币找零箱
                    BigDecimal supplementPaperAmount = collect.stream().filter(x -> "4".equals(x.getSupplementType()))
                            // 将对象的mongey取出来map为Bigdecimal
                            .map(SwStTvmSupplementCurrencyDetails::getSupplementAmount)
                            // 使用reduce聚合函数,实现累加器
                            .reduce(BigDecimal.ZERO, BigDecimal::add);

                    //硬币找零箱
                    BigDecimal supplementCoinAmount = collect.stream().filter(x -> "2".equals(x.getSupplementType()))
                            // 将对象的mongey取出来map为Bigdecimal
                            .map(SwStTvmSupplementCurrencyDetails::getSupplementAmount)
                            // 使用reduce聚合函数,实现累加器
                            .reduce(BigDecimal.ZERO, BigDecimal::add);

                    currency.setTotalSupplementPaperAmount(supplementPaperAmount);//合计补币纸币金额
                    currency.setTotalSupplementCoinAmount(supplementCoinAmount);//合计补币硬币金额
                    currency.setTotalSupplementAmount(supplementPaperAmount.add(supplementCoinAmount));//补币合计金额
                }else {
                    //作废主表数据
                    currency.setDelFlag("1");
                    currency.setInvalidStatus("1");
                    swStTvmSupplementCurrencyMapper.updateById(currency);
                }
                //作废子表数据
                for (SwStTvmSupplementCurrencyDetails x : detailsList) {
                    if (tvmCode.equals(x.getTvmCode())) {
                        x.setDelFlag("1");
                        x.setInvalidStatus("1");
                        //detailsInvalidList.add(x);
                        swStTvmSupplementCurrencyDetailsMapper.updateById(x);
                    }
                }
            }
        }*/
        //作废补币金额管理数据
        List<Map<String, Object>> supplementCurrency = swStTvmSupplementCurrencyMapper.getTvmSupplementCurrencyMap(param);
        if (supplementCurrency != null && supplementCurrency.size() > 0) {
            SwStTvmSupplementCurrency tvmSupplementCurrency = new SwStTvmSupplementCurrency();
            for (int i = 0; i < supplementCurrency.size(); i++) {
                Map<String, Object> map = supplementCurrency.get(i);
                Integer id = Integer.parseInt(map.get("id").toString());
                String tvmCashBoxType = (String) map.get("tvmCashBoxType");
                BigDecimal supplementCoinAmount = getBigDecimal(null);
                BigDecimal supplementPaperAmount = getBigDecimal(null);
                BigDecimal totalSupplementCoinAmount = getBigDecimal(map.get("totalSupplementCoinAmount"));
                BigDecimal totalSupplementPaperAmount = getBigDecimal(map.get("totalSupplementPaperAmount"));
                BigDecimal totalSupplementAmount = getBigDecimal(map.get("totalSupplementAmount"));
                if(!Objects.equals(tvmSupplementCurrency.getId(),id)){
                    tvmSupplementCurrency = new SwStTvmSupplementCurrency();
                }
                if("2".equals(tvmCashBoxType)){
                    //硬币找零箱
                    supplementCoinAmount = getBigDecimal(map.get("supplementAmount"));
                }
                if("4".equals(tvmCashBoxType)){
                    //纸币找零箱
                    supplementPaperAmount = getBigDecimal(map.get("supplementAmount"));
                }
                LambdaQueryWrapper<SwStTvmSupplementCurrencyDetails> supplementCurrencyDetailsWrapper = new LambdaQueryWrapper<>();
                supplementCurrencyDetailsWrapper.eq(SwStTvmSupplementCurrencyDetails::getRelationId, id)
                        .eq(SwStTvmSupplementCurrencyDetails::getTvmCode,tvmCode)
                        .eq(SwStTvmSupplementCurrencyDetails::getDelFlag,delFlag);
                SwStTvmSupplementCurrencyDetails swStTvmSupplementCurrencyDetails = new SwStTvmSupplementCurrencyDetails();
                swStTvmSupplementCurrencyDetails.setDelFlag("1");
                swStTvmSupplementCurrencyDetails.setInvalidStatus("1");
                swStTvmSupplementCurrencyDetailsMapper.update(swStTvmSupplementCurrencyDetails,supplementCurrencyDetailsWrapper);
                LambdaQueryWrapper<SwStTvmSupplementCurrencyDetails> currencyDetailsWrapper = new LambdaQueryWrapper<>();
                currencyDetailsWrapper.eq(SwStTvmSupplementCurrencyDetails::getRelationId, id)
                        .ne(SwStTvmSupplementCurrencyDetails::getTvmCode,tvmCode)
                        .ne(SwStTvmSupplementCurrencyDetails::getDelFlag,"1");
                List court = swStTvmSupplementCurrencyDetailsMapper.selectList(currencyDetailsWrapper);
                LambdaQueryWrapper<SwStTvmSupplementCurrency> cleanRecordWrapper = new LambdaQueryWrapper<>();
                cleanRecordWrapper.eq(SwStTvmSupplementCurrency::getId, id)
                        .eq(SwStTvmSupplementCurrency::getDelFlag,delFlag);
                SwStTvmSupplementCurrency swStTvmSupplementCurrency = new SwStTvmSupplementCurrency();
                if(court.size()>0){
                    if(tvmSupplementCurrency.getDelFlag()==null || "".equals(tvmSupplementCurrency.getDelFlag())){
                        tvmSupplementCurrency.setId(id);
                        tvmSupplementCurrency.setTotalSupplementCoinAmount(totalSupplementCoinAmount);
                        tvmSupplementCurrency.setTotalSupplementPaperAmount(totalSupplementPaperAmount);
                        tvmSupplementCurrency.setTotalSupplementAmount(totalSupplementAmount);
                    }
                    swStTvmSupplementCurrency.setTotalSupplementCoinAmount(tvmSupplementCurrency.getTotalSupplementCoinAmount().subtract(supplementCoinAmount));
                    swStTvmSupplementCurrency.setTotalSupplementPaperAmount(tvmSupplementCurrency.getTotalSupplementPaperAmount().subtract(supplementPaperAmount));
                    swStTvmSupplementCurrency.setTotalSupplementAmount(tvmSupplementCurrency.getTotalSupplementAmount().subtract(supplementCoinAmount).subtract(supplementPaperAmount));
                    swStTvmSupplementCurrencyMapper.update(swStTvmSupplementCurrency,cleanRecordWrapper);
                    tvmSupplementCurrency.setTotalSupplementCoinAmount(swStTvmSupplementCurrency.getTotalSupplementCoinAmount());
                    tvmSupplementCurrency.setTotalSupplementPaperAmount(swStTvmSupplementCurrency.getTotalSupplementPaperAmount());
                    tvmSupplementCurrency.setTotalSupplementAmount(swStTvmSupplementCurrency.getTotalSupplementAmount());
                    tvmSupplementCurrency.setDelFlag("0");
                }else{
                    swStTvmSupplementCurrency.setDelFlag("1");
                    swStTvmSupplementCurrency.setInvalidStatus("1");
                    swStTvmSupplementCurrencyMapper.update(swStTvmSupplementCurrency,cleanRecordWrapper);
                }
            }
        }
        //作废手工清出数据
        List<Map<String, Object>> swStHandworkCleanRecord = swStHandworkCleanRecordMapper.getHandworkCleanRecord(param);
        if (swStHandworkCleanRecord != null && swStHandworkCleanRecord.size() > 0) {
            SwStHandworkCleanRecord cleanRecord = new SwStHandworkCleanRecord();
            for (int i = 0; i < swStHandworkCleanRecord.size(); i++) {
                Map<String, Object> map = swStHandworkCleanRecord.get(i);
                Integer id = Integer.parseInt(map.get("id").toString());
                BigDecimal outAmount = getBigDecimal(map.get("clearOutAmount"));
                BigDecimal outPaperAmount = getBigDecimal(map.get("clearOutPaperAmount"));
                BigDecimal totalCleanCoinAmount = getBigDecimal(map.get("totalCleanCoinAmount"));
                BigDecimal totalCleanPaperAmount = getBigDecimal(map.get("totalCleanPaperAmount"));
                BigDecimal totalCleanAmount = getBigDecimal(map.get("totalCleanAmount"));
                if(!Objects.equals(cleanRecord.getId(),id)){
                    cleanRecord = new SwStHandworkCleanRecord();
                }
                LambdaQueryWrapper<SwStHandworkCleanRecordDetails> cleanRecordDetailsWrapper = new LambdaQueryWrapper<>();
                cleanRecordDetailsWrapper.eq(SwStHandworkCleanRecordDetails::getRelationId, id)
                        .eq(SwStHandworkCleanRecordDetails::getTvmCode,tvmCode)
                        .eq(SwStHandworkCleanRecordDetails::getDelFlag,delFlag);
                SwStHandworkCleanRecordDetails swStHandworkCleanRecordDetails = new SwStHandworkCleanRecordDetails();
                swStHandworkCleanRecordDetails.setDelFlag("1");
                swStHandworkCleanRecordDetails.setInvalidStatus("1");
                swStHandworkCleanRecordDetailsMapper.update(swStHandworkCleanRecordDetails,cleanRecordDetailsWrapper);
                LambdaQueryWrapper<SwStHandworkCleanRecordDetails> recordDetailsWrapper = new LambdaQueryWrapper<>();
                recordDetailsWrapper.eq(SwStHandworkCleanRecordDetails::getRelationId, id)
                        .ne(SwStHandworkCleanRecordDetails::getTvmCode,tvmCode)
                        .ne(SwStHandworkCleanRecordDetails::getDelFlag,"1");
                List court = swStHandworkCleanRecordDetailsMapper.selectList(recordDetailsWrapper);
                LambdaQueryWrapper<SwStHandworkCleanRecord> cleanRecordWrapper = new LambdaQueryWrapper<>();
                cleanRecordWrapper.eq(SwStHandworkCleanRecord::getId, id)
                        .eq(SwStHandworkCleanRecord::getDelFlag,delFlag);
                SwStHandworkCleanRecord handworkCleanRecord = new SwStHandworkCleanRecord();
                if(court.size()>0){
                    if(cleanRecord.getDelFlag()==null||"".equals(cleanRecord.getDelFlag())){
                        cleanRecord.setId(id);
                        cleanRecord.setTotalCleanCoinAmount(totalCleanCoinAmount);
                        cleanRecord.setTotalCleanPaperAmount(totalCleanPaperAmount);
                        cleanRecord.setTotalCleanAmount(totalCleanAmount);
                    }
                    handworkCleanRecord.setTotalCleanCoinAmount(cleanRecord.getTotalCleanCoinAmount().subtract(outAmount));
                    handworkCleanRecord.setTotalCleanPaperAmount(cleanRecord.getTotalCleanPaperAmount().subtract(outPaperAmount));
                    handworkCleanRecord.setTotalCleanAmount(cleanRecord.getTotalCleanAmount().subtract(outAmount).subtract(outPaperAmount));
                    swStHandworkCleanRecordMapper.update(handworkCleanRecord,cleanRecordWrapper);
                    cleanRecord.setTotalCleanCoinAmount(handworkCleanRecord.getTotalCleanCoinAmount());
                    cleanRecord.setTotalCleanPaperAmount(handworkCleanRecord.getTotalCleanPaperAmount());
                    cleanRecord.setTotalCleanAmount(handworkCleanRecord.getTotalCleanAmount());
                    cleanRecord.setDelFlag("0");
                }else{
                    handworkCleanRecord.setDelFlag("1");
                    handworkCleanRecord.setInvalidStatus("1");
                    swStHandworkCleanRecordMapper.update(handworkCleanRecord,cleanRecordWrapper);
                }
            }
        }
        //作废TVM结算已提交主页
        LambdaQueryWrapper<SwStTvmIncomeSettle> tvmIncomeSettleWrapper = new LambdaQueryWrapper<>();
        tvmIncomeSettleWrapper.eq(SwStTvmIncomeSettle::getLineCode, lineCode)
                .eq(SwStTvmIncomeSettle::getStationCode, stationCode)
                .eq(SwStTvmIncomeSettle::getTvmCode, tvmCode)
                .eq(SwStTvmIncomeSettle::getRecordTime, recordTime)
                .eq(SwStTvmIncomeSettle::getDelFlag, delFlag);
        SwStTvmIncomeSettle swStTvmIncomeSettle = new SwStTvmIncomeSettle();
        swStTvmIncomeSettle.setDelFlag("1");
        swStTvmIncomeSettle.setInvalidStatus("1");
        swStTvmIncomeSettleMapper.update(swStTvmIncomeSettle, tvmIncomeSettleWrapper);
        //作废TVM单台设备审核数据
        LambdaQueryWrapper<FareDifferencesInAudit> fareDifferencesInAuditWrapper = new LambdaQueryWrapper<>();
        fareDifferencesInAuditWrapper.eq(FareDifferencesInAudit::getLineCode, lineCode)
                .eq(FareDifferencesInAudit::getStationCode, stationCode)
                .eq(FareDifferencesInAudit::getTvmCode, tvmCode)
                .eq(FareDifferencesInAudit::getRecordTime, recordTime)
                .eq(FareDifferencesInAudit::getDelFlag, delFlag);
        FareDifferencesInAudit fareDifferencesInAudit = new FareDifferencesInAudit();
        fareDifferencesInAudit.setDelFlag("1");
        fareDifferencesInAudit.setInvalidStatus("1");
        fareDifferencesInAuditMapper.update(fareDifferencesInAudit, fareDifferencesInAuditWrapper);
        //作废TVM分钱箱数据
        LambdaQueryWrapper<SwAuTvmBoxAmountDifference> tvmBoxAmountDifferenceWrapper = new LambdaQueryWrapper<>();
        tvmBoxAmountDifferenceWrapper.eq(SwAuTvmBoxAmountDifference::getLineCode, lineCode)
                .eq(SwAuTvmBoxAmountDifference::getStationCode, stationCode)
                .eq(SwAuTvmBoxAmountDifference::getTvmCode, tvmCode)
                .eq(SwAuTvmBoxAmountDifference::getRecordTime, recordTime)
                .in(SwAuTvmBoxAmountDifference::getCashBoxType, "1", "2", "3", "4", "5")
                .eq(SwAuTvmBoxAmountDifference::getDelFlag, delFlag);
        SwAuTvmBoxAmountDifference swAuTvmBoxAmountDifference = new SwAuTvmBoxAmountDifference();
        swAuTvmBoxAmountDifference.setDelFlag("1");
        swAuTvmBoxAmountDifference.setInvalidStatus("1");
        swAuTvmBoxAmountDifferenceMapper.update(swAuTvmBoxAmountDifference, tvmBoxAmountDifferenceWrapper);
        //作废TVM单台设备票款差异协查
        LambdaQueryWrapper<SwAuTvmSingleAssist> tvmSingleAssistWrapper = new LambdaQueryWrapper<>();
        tvmSingleAssistWrapper.eq(SwAuTvmSingleAssist::getLineCode, lineCode)
                .eq(SwAuTvmSingleAssist::getStationCode, stationCode)
                .eq(SwAuTvmSingleAssist::getTvmCode, tvmCode)
                .eq(SwAuTvmSingleAssist::getIncomeTime, recordTime)
                .eq(SwAuTvmSingleAssist::getDelFlag, delFlag);
        SwAuTvmSingleAssist swAuTvmSingleAssist = new SwAuTvmSingleAssist();
        swAuTvmSingleAssist.setDelFlag("1");
        swAuTvmSingleAssist.setInvalidStatus("1");
        swAuTvmSingleAssistMapper.update(swAuTvmSingleAssist, tvmSingleAssistWrapper);
        //作废TVM分钱箱票款差异协查
        LambdaQueryWrapper<SwAuTvmMoneyAssist> tvmMoneyAssistWrapper = new LambdaQueryWrapper<>();
        tvmMoneyAssistWrapper.eq(SwAuTvmMoneyAssist::getLineCode, lineCode)
                .eq(SwAuTvmMoneyAssist::getStationCode, stationCode)
                .eq(SwAuTvmMoneyAssist::getTvmOrder, tvmCode)
                .eq(SwAuTvmMoneyAssist::getSettleTime, recordTime)
                .eq(SwAuTvmMoneyAssist::getDelFlag, delFlag);
        SwAuTvmMoneyAssist swAuTvmMoneyAssist = new SwAuTvmMoneyAssist();
        swAuTvmMoneyAssist.setDelFlag("1");
        swAuTvmMoneyAssist.setInvalidStatus("1");
        swAuTvmMoneyAssistMapper.update(swAuTvmMoneyAssist, tvmMoneyAssistWrapper);
        return true;
    }

    /**
     * 删除重复提交数据
     * @param id
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean delRepeatTvmData(int id,String flag) {
            //根据审核表id查找信息
			SwAuTvmAmountDefference swAuTvmAcount = swAuTvmAmountDefferenceMapper.selectById(id);			
			
			int incomeSettleId = swAuTvmAcount.getIncomeSettleId();
			String lineCode = swAuTvmAcount.getLineCode();
			String stationCode = swAuTvmAcount.getStationCode();
			String tvmCode = swAuTvmAcount.getTvmCode();
			
			String recordTime = "";
			try{
				recordTime = DateFormat.date_ex_str(swAuTvmAcount.getRecordTime());

			}catch(Exception e){
				
			}
			String delFlag = "0";
			
			//去重操作
			if("2".equals(flag)){
				   //作废TVM结算已提交主页
				LambdaQueryWrapper<SwStTvmIncomeSettle> tvmIncomeSettleWrapper = new LambdaQueryWrapper<>();
				tvmIncomeSettleWrapper.eq(SwStTvmIncomeSettle::getLineCode, lineCode)
						.eq(SwStTvmIncomeSettle::getStationCode, stationCode)
						.eq(SwStTvmIncomeSettle::getTvmCode, tvmCode)
						.eq(SwStTvmIncomeSettle::getRecordTime, recordTime)
				.ne(SwStTvmIncomeSettle::getId, incomeSettleId)
						.eq(SwStTvmIncomeSettle::getDelFlag, delFlag);
				SwStTvmIncomeSettle swStTvmIncomeSettle = new SwStTvmIncomeSettle();
				swStTvmIncomeSettle.setDelFlag("1");
				swStTvmIncomeSettle.setInvalidStatus("1");
				swStTvmIncomeSettleMapper.update(swStTvmIncomeSettle, tvmIncomeSettleWrapper);
				//作废TVM单台设备审核数据
				LambdaQueryWrapper<FareDifferencesInAudit> fareDifferencesInAuditWrapper = new LambdaQueryWrapper<>();
				fareDifferencesInAuditWrapper.eq(FareDifferencesInAudit::getLineCode, lineCode)
						.eq(FareDifferencesInAudit::getStationCode, stationCode)
						.eq(FareDifferencesInAudit::getTvmCode, tvmCode)
						.eq(FareDifferencesInAudit::getRecordTime, recordTime)
				.ne(FareDifferencesInAudit::getId, id)
						.eq(FareDifferencesInAudit::getDelFlag, delFlag);
				FareDifferencesInAudit fareDifferencesInAudit = new FareDifferencesInAudit();
				fareDifferencesInAudit.setDelFlag("1");
				fareDifferencesInAudit.setInvalidStatus("1");
				fareDifferencesInAuditMapper.update(fareDifferencesInAudit, fareDifferencesInAuditWrapper);
				//作废TVM分钱箱数据
				LambdaQueryWrapper<SwAuTvmBoxAmountDifference> tvmBoxAmountDifferenceWrapper = new LambdaQueryWrapper<>();
				tvmBoxAmountDifferenceWrapper.eq(SwAuTvmBoxAmountDifference::getLineCode, lineCode)
						.eq(SwAuTvmBoxAmountDifference::getStationCode, stationCode)
						.eq(SwAuTvmBoxAmountDifference::getTvmCode, tvmCode)
						.eq(SwAuTvmBoxAmountDifference::getRecordTime, recordTime)
						.in(SwAuTvmBoxAmountDifference::getCashBoxType, "1", "2", "3", "4", "5")
				.ne(SwAuTvmBoxAmountDifference::getIncomeSettleId, incomeSettleId)
						.eq(SwAuTvmBoxAmountDifference::getDelFlag, delFlag);
				SwAuTvmBoxAmountDifference swAuTvmBoxAmountDifference = new SwAuTvmBoxAmountDifference();
				swAuTvmBoxAmountDifference.setDelFlag("1");
				swAuTvmBoxAmountDifference.setInvalidStatus("1");
				swAuTvmBoxAmountDifferenceMapper.update(swAuTvmBoxAmountDifference, tvmBoxAmountDifferenceWrapper);
				return true;
                
			}
       
		
               //作废TVM结算已提交主页
				LambdaQueryWrapper<SwStTvmIncomeSettle> tvmIncomeSettleWrapper = new LambdaQueryWrapper<>();
				tvmIncomeSettleWrapper.eq(SwStTvmIncomeSettle::getLineCode, lineCode)
						.eq(SwStTvmIncomeSettle::getStationCode, stationCode)
						.eq(SwStTvmIncomeSettle::getTvmCode, tvmCode)
						.eq(SwStTvmIncomeSettle::getRecordTime, recordTime)
				        .eq(SwStTvmIncomeSettle::getId, incomeSettleId)
						.eq(SwStTvmIncomeSettle::getDelFlag, delFlag);
				SwStTvmIncomeSettle swStTvmIncomeSettle = new SwStTvmIncomeSettle();
				swStTvmIncomeSettle.setDelFlag("1");
				swStTvmIncomeSettle.setInvalidStatus("1");
				swStTvmIncomeSettleMapper.update(swStTvmIncomeSettle, tvmIncomeSettleWrapper);
				//作废TVM单台设备审核数据
				LambdaQueryWrapper<FareDifferencesInAudit> fareDifferencesInAuditWrapper = new LambdaQueryWrapper<>();
				fareDifferencesInAuditWrapper.eq(FareDifferencesInAudit::getLineCode, lineCode)
						.eq(FareDifferencesInAudit::getStationCode, stationCode)
						.eq(FareDifferencesInAudit::getTvmCode, tvmCode)
						.eq(FareDifferencesInAudit::getRecordTime, recordTime)
				        .eq(FareDifferencesInAudit::getId, id)
						.eq(FareDifferencesInAudit::getDelFlag, delFlag);
				FareDifferencesInAudit fareDifferencesInAudit = new FareDifferencesInAudit();
				fareDifferencesInAudit.setDelFlag("1");
				fareDifferencesInAudit.setInvalidStatus("1");
				fareDifferencesInAuditMapper.update(fareDifferencesInAudit, fareDifferencesInAuditWrapper);
				//作废TVM分钱箱数据
				LambdaQueryWrapper<SwAuTvmBoxAmountDifference> tvmBoxAmountDifferenceWrapper = new LambdaQueryWrapper<>();
				tvmBoxAmountDifferenceWrapper.eq(SwAuTvmBoxAmountDifference::getLineCode, lineCode)
						.eq(SwAuTvmBoxAmountDifference::getStationCode, stationCode)
						.eq(SwAuTvmBoxAmountDifference::getTvmCode, tvmCode)
						.eq(SwAuTvmBoxAmountDifference::getRecordTime, recordTime)
						.in(SwAuTvmBoxAmountDifference::getCashBoxType, "1", "2", "3", "4", "5")
				        .eq(SwAuTvmBoxAmountDifference::getIncomeSettleId, incomeSettleId)
						.eq(SwAuTvmBoxAmountDifference::getDelFlag, delFlag);
				SwAuTvmBoxAmountDifference swAuTvmBoxAmountDifference = new SwAuTvmBoxAmountDifference();
				swAuTvmBoxAmountDifference.setDelFlag("1");
				swAuTvmBoxAmountDifference.setInvalidStatus("1");
				swAuTvmBoxAmountDifferenceMapper.update(swAuTvmBoxAmountDifference, tvmBoxAmountDifferenceWrapper);
				return true;
    }
    public static BigDecimal getBigDecimal( Object value ) {
        BigDecimal ret = new BigDecimal("0.00");
        if( value != null ) {
            String data = String.valueOf(value);
            ret = new BigDecimal(data);
        }
        return ret;
    }
}
